<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>embedme: inc/Upgrader.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.8 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>文件成员</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_9fa8504274c7932718f9f402b9f9e583.html">inc</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Upgrader.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef __UPGRADER_H__</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define __UPGRADER_H__</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_thread_8h.html">Thread.h</a>&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_socket_8h.html">Socket.h</a>&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_timer_8h.html">Timer.h</a>&quot;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_event_8h.html">Event.h</a>&quot;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &lt;pthread.h&gt;</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#define UGPACK_TYPE_INFO  0xAA</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#define UGPACK_TYPE_DATA  0x66</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#define UGPACK_TYPE_STAT  0xFF</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="keyword">typedef</span> <span class="keyword">enum</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;{</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;    UPGRADE_STATUS_SUCESS=0,    <span class="comment">/* 升级成功 */</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;    UPGRADE_STATUS_MD5ERR,      <span class="comment">/* MD5校验错误,数据不完整 */</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    UPGRADE_STATUS_FILEERR,     <span class="comment">/* 非法升级包,升级包无法解压 */</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;}UPGRADE_STATUS_E;</div>
<div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="struct_u_g_p_a_c_k___h_e_a_d_e_r___s.html">   21</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;{</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    <span class="keywordtype">char</span> ugpack_tag[8];   <span class="comment">//包头标识{&#39;*&#39;,&#39;A&#39;,&#39;R&#39;,&#39;E&#39;,&#39;T&#39;,&#39;Y&#39;,&#39;H&#39;,&#39;#&#39;};</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    sint32 ugpack_type;   <span class="comment">//包类型:&#39;0xAA&#39;表示文件信息,&#39;0x66&#39;表示数据,&#39;0xFF&#39;表示升级状态</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;    uint32 size;          <span class="comment">//信息包时表示文件总长度,数据包时表示已传输的文件长度，状态包时00是升级失败,01是升级成功</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;    uint32 pack_no;       <span class="comment">//包序号</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <span class="keywordtype">char</span> ext_data[32];    <span class="comment">//额外包头数据(可以用来放md5sum值)</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;}<a class="code" href="struct_u_g_p_a_c_k___h_e_a_d_e_r___s.html">UGPACK_HEADER_S</a>;</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="class_upgrader.html">   31</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_upgrader.html">Upgrader</a>:<span class="keyword">public</span> <a class="code" href="class_runnable_protocol.html">RunnableProtocol</a>{</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    <span class="keyword">static</span> <a class="code" href="class_upgrader.html">Upgrader</a>&amp; getInstance()</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    {</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;        <span class="keyword">static</span> <a class="code" href="class_upgrader.html">Upgrader</a> instance;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        <span class="keywordflow">return</span> instance;</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    }</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    ~<a class="code" href="class_upgrader.html">Upgrader</a>();</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    <a class="code" href="class_upgrader.html">Upgrader</a>();</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <span class="keywordtype">void</span> socketUpgradeServerProc();</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    sint32 handleClientConnection(<a class="code" href="class_tcp_socket.html">TcpSocket</a>&amp; socket);</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    sint32 ackClient(<a class="code" href="class_tcp_socket.html">TcpSocket</a> socket, <a class="code" href="struct_u_g_p_a_c_k___h_e_a_d_e_r___s.html">UGPACK_HEADER_S</a> header);</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    sint32 checkMd5Sum(std::string fileName,std::string md5File);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    sint32 updateApp();</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="keywordtype">void</span> run();</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <a class="code" href="class_tcp_socket.html">TcpSocket</a> m_sersock;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    pthread_t m_serverThread;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    sint32 m_clisockfd;    <span class="comment">//连接客户端的socket fd</span></div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <a class="code" href="class_periodic_timer.html">PeriodicTimer</a>* testTimer;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;};</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="class_tcp_socket_html"><div class="ttname"><a href="class_tcp_socket.html">TcpSocket</a></div><div class="ttdoc">TcpSocket类 </div><div class="ttdef"><b>Definition:</b> Socket.h:125</div></div>
<div class="ttc" id="class_periodic_timer_html"><div class="ttname"><a href="class_periodic_timer.html">PeriodicTimer</a></div><div class="ttdoc">周期定时器类 </div><div class="ttdef"><b>Definition:</b> Timer.h:84</div></div>
<div class="ttc" id="_socket_8h_html"><div class="ttname"><a href="_socket_8h.html">Socket.h</a></div></div>
<div class="ttc" id="_timer_8h_html"><div class="ttname"><a href="_timer_8h.html">Timer.h</a></div></div>
<div class="ttc" id="struct_u_g_p_a_c_k___h_e_a_d_e_r___s_html"><div class="ttname"><a href="struct_u_g_p_a_c_k___h_e_a_d_e_r___s.html">UGPACK_HEADER_S</a></div><div class="ttdef"><b>Definition:</b> Upgrader.h:21</div></div>
<div class="ttc" id="_thread_8h_html"><div class="ttname"><a href="_thread_8h.html">Thread.h</a></div></div>
<div class="ttc" id="_event_8h_html"><div class="ttname"><a href="_event_8h.html">Event.h</a></div></div>
<div class="ttc" id="class_runnable_protocol_html"><div class="ttname"><a href="class_runnable_protocol.html">RunnableProtocol</a></div><div class="ttdoc">线程接口 </div><div class="ttdef"><b>Definition:</b> Thread.h:36</div></div>
<div class="ttc" id="class_upgrader_html"><div class="ttname"><a href="class_upgrader.html">Upgrader</a></div><div class="ttdef"><b>Definition:</b> Upgrader.h:31</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2016年 一月 12日 星期二 15:46:00 , 为 embedme使用  &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.8
</small></address>
</body>
</html>
